<template>
	<view>
		<view class="login-box" v-if='showPopup'>
			<view class="content">
				<view class="title">
					用户隐私协议
				</view>
				<view class="text">
					<scroll-view scroll-y="true" style="height: 600rpx;">
						<view v-html="info"></view>
					</scroll-view>
				</view>
				<view :class="btnClass" @tap="select">
					<view class="btnbox" :style="{border: isread?'2rpx solid #fff':'2rpx solid #999'}">
						<image v-if='isread' src="../../static/gx.png" mode="widthFix"></image>
					</view>
					<view class="info">
						我已仔细阅读并同意<text>用户隐私协议</text>
					</view>
				</view>
				<view class="btn-box">
					<view @tap="cancel">
						取消
					</view>
					<view @tap="confirm" style="background-color: #FE4D34;color: #fff;">
						确认
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "privacyBox",
		props: {
			showPopup: {
				type: Boolean,
				default: false,
			},
			info: {
				type: String,
				default: '',
			}
		},
		data() {
			return {
				btnClass: ['readBox'],
				isread: false,
			};
		},
		methods: {
			cancel() {
				this.$emit('update:showPopup',false)
				this.$emit('change','cancel')
			},
			confirm() {
				if (!this.isread) {
					this.btnClass = ['readBox', 'dd']
					setTimeout(() => {
						this.btnClass = ['readBox']
					}, 500)
					return
				}
				this.$emit('update:showPopup',false)
				this.$emit('change','confirm')
			},
			select() {
				this.isread = !this.isread
			},
		}
	}
</script>

<style lang="scss">
	
		.btn {
			position: fixed;
			bottom: 15rpx;
			width: 100%;
	
			view {
				margin: 30rpx;
				box-shadow: 0 10rpx 20rpx #eee;
				text-align: center;
				font-size: 16px;
				font-weight: bold;
				color: #fff;
				border-radius: 60rpx;
				background-color: #FE4D34;
				padding: 30rpx;
				transition: 0.2s;
	
				&:active {
					opacity: 0.7;
				}
			}
		}
		.login-box {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			height: 100%;
			background-color: rgba(0, 0, 0, 0.5);
			z-index: 1000;
			display: flex;
			align-items: center;
			justify-content: center;
		
			.content {
				width: 80%;
				display: flex;
				flex-direction: column;
				background-color: #fff;
				border-radius: 15rpx;
				margin-bottom: 200rpx;
				overflow: hidden;
		
				.title {
					text-align: center;
					padding: 30rpx;
					font-size: 16px;
					font-weight: bold;
					color: #333;
				}
		
				.text {
					padding: 0 0rpx;
					padding-bottom: 10rpx;
					text {
						color: #FE4D34;
					}
				}
		
				.btn-box {
					display: flex;
					border-top: 1rpx solid #eee;
		
					view {
						flex: 1;
						color: #999;
						text-align: center;
						justify-content: center;
						border-left: 1rpx solid #eee;
						display: flex;
						align-items: center;
						padding: 30rpx;
						transition: 0.2s;
		
						&:active {
							opacity: 0.5;
						}
					}
				}
			}
		
		}
		.readBox {
			padding: 15rpx 0;
			width: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #333;
			font-size: 14px;
		
			.btnbox {
				margin-right: 20rpx;
				display: flex;
				width: 40rpx;
				height: 40rpx;
				border-radius: 50%;
				border: 2rpx solid #999;
		
				image {
					width: 100%;
					height: 100%;
				}
			}
		
			.info {
				color: #333;
				font-size: 14px;
		
				text {
					color: #FE4D34;
				}
			}
		
		}
		.dd {
			animation: shake 1s;
		}
		
		@keyframes shake {
		
			0%,
			100% {
				transform: translateX(0);
			}
		
			10%,
			30%,
			50%,
			70%,
			90% {
				transform: translateX(-5px);
			}
		
			20%,
			40%,
			60%,
			80% {
				transform: translateX(5px);
			}
		}
</style>
